<?php
class CreateController extends Controller {

	/**
	 * 创建相册
	 */
	public function actionIndex () {
		$model = 'Album';
		$album = new $model();
		if (isset($_POST[$model])) {
			$album->attributes = $_POST[$model];
			if ($album->save()) {
				$aid = $album->primaryKey;
				
				// 标识权限
				$this->module->setIdentity($aid, 'author');
				
				$this->redirect(array(
					'/album/upload',
					'id' => $aid 
				));
			}
		}
		$ajax = Yii::app()->request->getIsAjaxRequest();
		$varArray = array(
			'album' => $album,
			'ajax' => $ajax 
		);
		
		if ($ajax)
			$this->renderPartial('index', $varArray, false, true);
		else
			$this->render('index', $varArray);
	}
}

?>